<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" th:href="@{/common/css/sapar.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/common/css/common.css}" />
<script type="text/javascript" th:src="@{/common/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/common/js/sapar.js}"></script>
<script type="text/javascript" th:src="@{/common/js/WdatePicker.js}"></script>
<title>系统首页</title>
</head>

<body>
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>修改密码</h2>
            </div>
			<div class="subfiled-content">
	            <form class="saper-form">
	            	<div class="kv-item clearfix">
	                    <label>用户名：</label>
	                    <div class="kv-item-content">
	                        <div class="user-name" style="line-height:30px;"><span th:text="${session.username}"></span></div>
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>原密码：</label>
	                    <div class="kv-item-content">
	                        <input id="txtOldPwd" type="password" placeholder="原密码" name="oldPassword">
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>新密码：</label>
	                    <div class="kv-item-content">
	                        <input  id="txtNewPwd" type="password" placeholder="新密码" name="newPassword">
	                    </div>
	                </div>
	                <div class="kv-item clearfix">
	                    <label><span class="impInfo">*</span>确认密码：</label>
	                    <div class="kv-item-content">
	                        <input id="txtRePwd" type="password" placeholder="确认密码" name="rePassword">
	                    </div>
	                </div>

	                <div class="buttons">
	                    <a href="javascript:;" class="sapar-btn sapar-btn-recom">确定</a>
	                </div>
	            </form>
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>
    
</body>

<script type="text/javascript">
	$("a").click(function(){
		var txtOldPwd=$("#txtOldPwd").val();
		var txtNewPwd=$("#txtNewPwd").val();
		var txtRePwd=$("#txtRePwd").val();
		if (txtOldPwd ==""||txtNewPwd ==""||txtRePwd == ""){
			alert("密码不能为空");
		}else {
			if(txtOldPwd==txtNewPwd){
				alert("新旧密码不能相同");
			}else{
				if (txtNewPwd==txtRePwd){
					$.post("/editPassword",{"oldPwd":txtOldPwd,"newPwd":txtNewPwd},function(data){
						if(data == '1'){
							top.location.replace("/logout");
						}else{
							alert("原密码错误！");
						}
					});
				}else{
					alert("两次密码输入不一致");
				}
			}
		}
		return false;
	});
</script>
</html>